package com.zijie;

import java.util.Scanner;

public class Q1 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int T = scanner.nextInt();
        while (T-- > 0) {
            int A = scanner.nextInt();
            int B = scanner.nextInt();
            int C = scanner.nextInt();
            int result = 0;

            if (A > 0) {
                result = 0;
            } else {
                int zCount = (A == 0) ? 1 : 2;
                int ySquare=A-B;
                if(ySquare<0) {
                    result=0;
                } else {
                    int yCount=(ySquare==0)?1:2;
                    long aSquareYSquare=(long)A*A*ySquare;
                    long xSquare=-(aSquareYSquare+C);
                    if(xSquare<0) {
                        result=0;
                    } else {
                        int xCount=(xSquare==0)?1:2;
                        result=zCount*yCount*xCount;
                    }
                }
            }
            System.out.println(result);
        }
        scanner.close();
    }


}
